<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row layui-col-space5">
                <form class="layui-form" lay-filter="myform" id="myform">
                    <div class="layui-form-item">

                        <label class="layui-form-label">学院/系</label>
                        <div class="layui-input-inline">
                            <select name="collegeId" id="collegeId"></select>
                        </div>
                        <label class="layui-form-label">考试专业</label>
                        <div class="layui-input-inline">
                            <select name="majorId" id="majorId"></select>
                        </div>
                        <label class="layui-form-label">考试科目</label>
                        <div class="layui-input-inline">
                            <select name="categoryId" id="categoryId"></select>
                        </div>
                        <label class="layui-form-label">学生类型</label>
                        <div class="layui-input-inline">
                            <select name="studentType" id="studentType"></select>
                        </div>

                        <label class="layui-form-label">考生年级</label>
                        <div class="layui-input-inline">
                            <select name="grade" id="grade"></select>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">考试学年</label>
                        <div class="layui-input-inline">
                            <select name="gradeYear" id="gradeYear"></select>
                        </div>
                        <label class="layui-form-label">考试学期</label>
                        <div class="layui-input-inline">
                            <select name="semester" id="semester"></select>
                        </div>
                        <label class="layui-form-label">考试阶段</label>
                        <div class="layui-input-inline">
                            <select name="testPhase" id="testPhase"></select>
                        </div>
                        <label class="layui-form-label">A/B/C卷</label>
                        <div class="layui-input-inline">
                            <select name="paperType" id="paperType"></select>
                        </div>
                        <label class="layui-form-label">考试方式</label>
                        <div class="layui-input-inline">
                            <select name="testType" id="testType"></select>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">中/英文</label>
                        <div class="layui-input-inline">
                            <select name="lg" id="lg"></select>
                        </div>
                        <label class="layui-form-label">考试时长</label>
                        <div class="layui-input-inline">
                            <input type="number" name="howlong" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分钟</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">每道单选</label>
                        <div class="layui-input-inline" style="width: 128px!important;">
                            <input type="text" name="score1" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分</div>
                        <label class="layui-form-label">每道多选</label>
                        <div class="layui-input-inline" style="width: 128px!important;">
                            <input type="text" name="score2" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分</div>
                        <label class="layui-form-label">每道判断</label>
                        <div class="layui-input-inline" style="width: 128px!important;">
                            <input type="text" name="score3" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分</div>
                        <label class="layui-form-label">每道简答</label>
                        <div class="layui-input-inline" style="width: 128px!important;">
                            <input type="text" name="score4" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分</div>
                        <label class="layui-form-label">每道计算分析</label>
                        <div class="layui-input-inline" style="width: 128px!important;">
                            <input type="text" name="score5" autocomplete="off" class="layui-input">
                        </div><div class="layui-form-mid">分</div>
                    </div>
                </form>
                <table class="layui-hide" id="main-table" lay-filter="main-table"></table>
            </div>
        </div>
    </div>
</div>
<button type="button" id="importWord" style="display: none">导入</button>
<script th:inline="none"></script>
<script>
    let joinid = `[[${joinid}]]`;
    layui.use(['table','form'], function(){
        var table = layui.table,
            form = layui.form;
        createSelect("paper-type","paperType",form,'','请选择');
        createSelect("semester","semester",form,1,'请选择');
        createSelect("test-type","testType",form,1,'请选择');
        createSelect("test-phase","testPhase",form,'','请选择');
        createSelect("student-type","studentType",form,'','请选择');
        createSelect("paper-lg","lg",form,1,'请选择');
        select('grade/getPageList?limit=40&page=1' , 'grade',form,'name','id')
        select('major/getPageList?limit=30&page=1' , 'majorId',form,'name','id')
        select('libCategory/getPageList?limit=40&page=1' , 'categoryId',form,'name','id')
        select('gradeYear/getPageList?limit=40&page=1' , 'gradeYear',form,'name','id')
        select('college/getPageList?limit=40&page=1' , 'collegeId',form,'name','id')
        table.render({
            elem: '#main-table'
            ,height: 690
            ,url: 'libQuestion/getJoinResult'
            ,title: '题目列表'
            ,where:{joinid:joinid}
            ,toolbar: '#toolbar'
            ,cols: [
                [
                    {type: 'numbers'}
                    ,{type: 'checkbox'}
                    ,{field: 'code', title: "编号",width:90}
                    ,{field: 'text2', title: "题干",width:320}
                    ,{field: 'questionTypeTxt',title: "题型",width:100}
                    ,{field: 'pianName', title: "篇",width:180}
                    ,{field: 'chapterName', title: "章",width:180}
                    ,{field: 'jieName', title: "节",width:250}
                    ,{field: 'knowledgeName',title: "知识点",width:250}
                    ,{field: 'difficultyTxt',title: "难度",width:90}
                    ,{field: 'answerText',title: "答案",width:220}
                    ,{field: 'analysis',title: "解析",width:220}
                    ,{field: 'contentTypeTxt',title: "试题类型",width:120}
                    ,{field: 'paperTypeTxt',title: "试卷类型",width:120}
                    ,{field: 'lgTxt',title: "语言",width:90}
                ]
            ]
            ,done:function(){
                enableRowClick(table,form,'main-table',"main-table");
            }
        });
        //头工具栏事件
        table.on('toolbar(main-table)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'delete':
                    var data = checkStatus.data;
                    if(data.length>0){
                        var values = {joinid:joinid};
                        var ids=[];
                        $.each(data,function(i,v){
                            ids.push(v.id);
                        })
                        values['ids'] = ids.join(",");
                        layer.confirm('确定要删除当前行么?', {icon: 3, title:'提示'}, function(index){
                            axios.post("libQuestion/deleteJoined",values).then(res=>{
                                if(res.data.code==0){
                                    table.reload("main-table");
                                    layer.close(index)
                                }
                                top.layer.msg(res.data.msg)
                            })
                        });
                    }else{
                        layer.msg("请选择操作数据!")
                    }
                    break;
            };
        });
        loadData();
        function loadData(){
            var entity = getEntityInfo(joinid,"paper/getById");
            form.val("myform",entity);

        }
    });


</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
    </div>
</script>
</body>
</html>